import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
import scala.io.{BufferedSource, Source}

object HelloScala {

  def main(args: Array[String]): Unit = {

    val arr = new Array[Int](10)

    val arr1 = new Array[String](10)

    arr(0)
    //省略关键字new，自动推断
    val arr3 = Array(1,2,3)

    val array: Array[Int] = (1 to 10).toArray

    val arrayBuffer = new ArrayBuffer[Int]()
    arrayBuffer += 1
    arrayBuffer += (2,3,4,5)
    arrayBuffer ++= Array(6,7,8)
    arrayBuffer.foreach(println(_))

    arrayBuffer.insert(2,10)
    arrayBuffer.insert(2,20,30)

    //变长数组转为定长数组 toArray
    val array1 = arrayBuffer.toArray

    //定长数组转为变长数组 toBuffer
    val buffer = arr.toBuffer

    for(i <- arr){
      println(i)
    }

  }

  def getTextFile(): Unit ={
    val source: BufferedSource = Source.fromFile("src\\a.txt")
    val iterator: Iterator[String] = source.getLines()

  }
}
